<template>

  <div style="display: flex;height: calc(100% - 10px);">
    <div id="left">
      <div id="left-top">
        <span class="common-grey-text" style="font-size: 14px">近期消息</span>
      </div>

      <div id="left-bottom">
        <div v-for="user in privateList" class="user-box" @click="clickUserBox(user, $event)">
          <img :src="user.img" alt="用户头像" class="user-img">

          <div class="left-bottom-text-box">
            <span>{{ user.name }}</span>
            <span class="user-name-bottom">id: {{ user.id }}</span>
          </div>
        </div>
      </div>
    </div>

    <div id="right">
      <div id="right-top">
        {{ activeUser.name }}
      </div>

      <div id="right-bottom">

      </div>

    </div>
  </div>

</template>

<script setup>
import {ref} from "vue";

const props = defineProps(['user_id']);

const privateList = ref([
  {
    id: "1",
    name: "用户名1",
    img: "https://i2.hdslb.com/bfs/face/45db0e5d57edc4828fd5e8f16d78ab0d3f540a19.jpg@46w_46h_1c.webp"
  },
  {
    id: "2",
    name: "用户名2",
    img: "https://i2.hdslb.com/bfs/face/45db0e5d57edc4828fd5e8f16d78ab0d3f540a19.jpg@46w_46h_1c.webp"
  }
])

const privateMessage = ref([]);

const activeUser = ref({name: ""});
const activeUserDiv = ref(void 0);

function clickUserBox(user, event){
  activeUser.value = user;
  let target = event.currentTarget;
  let activeTarget = activeUserDiv.value;
  if (activeTarget){
    activeTarget.style.backgroundColor="";
  }
  target.style.backgroundColor="#e4e5e6";
  activeUserDiv.value = target;
}

</script>

<style scoped>

#left{
  width: 240px;
  border-right: 1px solid #e9eaec;
  position: relative;
  height: 100%;
  background-color: #fff;

  border-bottom-left-radius: 4px;
  border-top-left-radius: 4px;
}

#left-top{
  padding-left: 24px;
  line-height: 35px;
  height: 36px;
  border-bottom: 1px solid #e9eaec;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  overflow: hidden;
}

#left-bottom{
  height: calc(100% - 36px);
  position: relative;
  overflow: hidden;
}

.user-box{
  box-sizing: border-box;
  width: 100%;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
  padding: 19px 24px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.user-img{
  height: 48px;
  width: 48px;
  border-radius: 50%;
  margin-right: 8px;
}

.left-bottom-text-box{
  display: flex;
  flex-direction: column;
}

.user-name-bottom{
  color: #999;
  padding: 8px 0;
  margin-bottom: -6px;
}

#right{
  width: calc(100% - 240px);
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  height: 100%;
  background-color: #fff;

  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

#right-top{
  height: 36px;
  flex-shrink: 0;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  border-bottom: 1px solid #e9eaec;
  position: relative;
  text-align: center;
  color: #333;
}

#right-bottom{
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  position: relative;
  background-color: #f4f5f7;
  height: calc(100% - 36px);

  border-bottom-right-radius: 4px;
}

</style>